package com.wanwu.channel.service.strategy;


import com.wanwu.channel.common.enums.PayType;

import java.util.HashMap;
import java.util.Map;

/**
 * @author zhy
 * @date 2020-1-2
 * @descrption 支付策略工厂
 */
public class StrategyFactory {

    private static final Map<Integer, PayStrategy> strategyMap = new HashMap<>();

    static {
        strategyMap.put(PayType.ALIPAY_APP.value(), new AlipayAppStrategy());
    }

    private StrategyFactory() {
    }

    private static class InstanceHolder {
        private static StrategyFactory instance = new StrategyFactory();
    }

    public static StrategyFactory getInstance() {
        return InstanceHolder.instance;
    }

    public PayStrategy creator(Integer type) {
        return strategyMap.get(type);
    }

}
